// 三个页面共有的轮播图页面
(function (){
    var amSlider = $(".am-slides");
    new AjaxRequest({
        url :'../type?infoType=3&pn=1',
        type : 'GET',
        sucCallback : function (res) {
            console.log(res);
            if (res.status === true) {
                var htmlStr = '';
                var jData = res.datas[0].list;
                  // 第一张
                    htmlStr += '<li data-id="' + jData[2].infoId + '" class="clone" aria-hidden="true" style="width: 640px; float: left; display: block;">\n' +
                        '                <img src="' + jData[2].infoPic + '" draggable="false">\n' +
                        '                <div class="pet_slider_font">\n' +
                        '                    <span class="pet_slider_emoji"> ' + jData[2].infoHeadline + '</span>\n' +
                        '                    <span>' + jData[2].infoType + '</span>\n' +
                        '                </div>\n' +
                        '                <div class="pet_slider_shadow"></div>\n' +
                        '          </li>';

                    for (var i = 0; i < 3; i++) {
                        htmlStr += '<li data-id="' + jData[i].infoId + '" style="width: 640px; float: left; display: block;" class="am-active-slide">\n' +
                            '                <img src="' + jData[i].infoPic + '" draggable="false">\n' +
                            '                <div class="pet_slider_font">\n' +
                            '                    <span class="pet_slider_emoji">' + jData[i].infoHeadline + '</span>\n' +
                            '                    <span>' + jData[i].infoType + '</span>\n' +
                            '                </div>\n' +
                            '                <div class="pet_slider_shadow"></div>\n' +
                            '          </li>'
                    }

                    // 最后一张
                    htmlStr += '<li data-id="' + jData[0].infoId + '" class="clone" aria-hidden="true" style="width: 640px; float: left; display: block;">\n' +
                        '                <img src="' + jData[0].infoPic + '" draggable="false">\n' +
                        '                <div class="pet_slider_font">\n' +
                        '                    <span class="pet_slider_emoji"> ' + jData[0].infoHeadline + '</span>\n' +
                        '                    <span>' + jData[0].infoType + '</span>\n' +
                        '                </div>\n' +
                        '                <div class="pet_slider_shadow"></div>\n' +
                        '          </li>';
                amSlider.html(htmlStr);

                var $li = amSlider.children('li');
                var width = $(".am-viewport").width();
                $li.css({
                    height : width * 0.45,
                    width : width
                });

                $li.click(function () {
                    window.location.href = "./knowledgeDetail.html?id=" + $(this).data("id")
                })
            }else {
                openModal({
                    describe : "轮播图加载错误！显示默认图片"
                })
            }
        }
    })
})();